<!--
 * @FilePath     : /study_code/vue2.x/mixin1.html
 * @Description  : mixin 简单使用
 * @Date         : 2025-05-03 08:52:55
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-05-03 08:52:55
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
    <link rel="stylesheet" href="" />
  </head>
  <body>
    <div id="test"></div>

    <script src="/vue/dist/vue.min.js"></script>
    <script src="./common.js"></script>
    <script>
      // 定义一个混入对象
      var myMixin = {
        created() {
          this.hello()
        },
        methods: {
          hello() {
            console.log('hello from mixin')
          },
        },
      }

      // 定义一个使用混入对象的组件
      var Component = Vue.extend({
        mixins: [myMixin],
        template: '<h4>标题</h4>',
      })

      var component = new Component() // "hello from mixin!"

      component.$mount('#test')

      /* var app = new Vue({
        el: '#app',
        data: function () {
          return {}
        },
      }) */
    </script>
  </body>
</html>
